package com.yxe.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yxe.mapper.CollectionMapper;
import com.yxe.pojo.Collection;
import com.yxe.pojo.House;
import com.yxe.service.CollectionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yang
 * @since 2022-12-14
 */
@Service
public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collection> implements CollectionService {

    @Resource
    private CollectionMapper collectionMapper;

    /**
     * 添加收藏
     * @param collection
     */
    @Override
    public void insertCollection(Collection collection) {

        collectionMapper.insert(collection);

    }

    /**
     * 取消收藏
     * @param id
     */
    @Override
    public void deleteCollection(Integer id) {
        collectionMapper.deleteById(id);
    }

    /**
     * 所有收藏
     * @return
     */
    @Override
    public List<House> findAll(Integer userId) {
        return collectionMapper.findAll(userId);
    }

}
